<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/jquery-weui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/index.css" />
    <link rel="stylesheet" type="text/css" href="../../css/order.css" />
    <title>确认收货单</title>
    <script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/baseConfig.js" type="text/javascript" charset="utf-8"></script>
    <script src=" http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>

<body>
    <!--<div id="header">
			<div class="header-title" style="position: fixed;top: 0;">
				<img src="../../img/left.png" class="left"/>
				<span>入库单</span>
			</div>
		</div>	-->
    <div class="imgWarp" style="margin-top: 0;">

    </div>
    <div class="weui-gallery" style="display: none">
        <span class="weui-gallery__img">
				<img src="" style="width: 100%;height: auto;margin-top: 50%"/>
			</span>
    </div>
    <div class="demos-content-padded" style="padding: 0.3rem 1.1rem;">
        <a href="javascript:;" class="weui-btn weui-btn_primary">已收到收货单</a>
    </div>
</body>
<script type="text/javascript">
    $(document).ready(function() {
        baseConfig.historyBack()
            //获取入库单图片
        $.ajax({
            type: "get",
            url: baseConfig.localHttp + "weChatApi/fgclient/getStorePic",
            async: false,
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            data: {
                orderNo: baseConfig.GetQueryString("orderNo")
            },
            success: function(data) {
                console.log(data)
                var status = baseConfig.GetQueryString("status")
                if (status == 1) {
                    $(".demos-content-padded").hide()
                } else {
                    $(".demos-content-padded").hide()
                }
                if (data.code == 100) {
                    //							function CheckImgExists(imgurl) {  
                    //							  var ImgObj = new Image(); //判断图片是否存在  
                    //							  ImgObj.src = imgurl;  
                    //							  //没有图片，则返回-1  
                    //							  if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {  
                    //									$(".imgWarp").html("<img src="+baseConfig.imglocalHttp+data.content+">")							    
                    //							  } else {  
                    //							  		$.toast("暂无数据", "cancel");
                    //							  }  
                    //							}
                    //							CheckImgExists(baseConfig.imglocalHttp+data.content)
                    $(".imgWarp").html("<img src=" + baseConfig.imglocalHttp + data.content + ">")
                    var imgsurl = [];
                    var nowurl = '';
                    var imgObj = $(".imgWarp img");
                    for (var i = 0; i < imgObj.length; i++) {
                        imgsurl[i] = imgObj[i].src;
                        imgObj[i].onclick = function() {
                            nowurl = this.src;
                            wx.previewImage({
                                current: nowurl,
                                urls: imgsurl
                            });
                        }
                    }
                    // $(".imgWarp img").on("click", function() {
                    // $(".weui-gallery").show()
                    // $(".weui-gallery__img img").attr("src", baseConfig.imglocalHttp + data.content)
                    // $(".weui-gallery").on("click", function() {
                    //     $(this).hide()
                    // })

                    // })
                } else {
                    $(".demos-content-padded").hide()
                    $.toptip(data.content, 1200, 'error')
                }
            },
            error: function() {
                $.toast("请求失败", "cancel");
            }
        })
        $(".weui-btn").on("click", function() {
            $.ajax({
                type: "get",
                url: baseConfig.localHttp + "weChatApi/fgclient/confirmInStore",
                async: false,
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                },
                data: {
                    orderNo: baseConfig.GetQueryString("orderNo")
                },
                success: function(data) {
                    console.log(data)
                    if (data.code == 100) {
                        $.toptip(data.content, 1200, 'success')
                        setTimeout(function() {
                            window.location.replace(document.referrer)
                        }, 1200)
                    } else {
                        $.toptip(data.content, 1200, 'error')
                    }
                },
                error: function() {
                    $.hideLoading();
                    $.toast("请求失败", "cancel");
                }
            })
        })
    })
</script>

</html>